package cn.wmw.xyy.web.controller;

import cn.wmw.result.JsonResult;
import cn.wmw.result.PageList;
import cn.wmw.xyy.doc.CourseDoc;
import cn.wmw.xyy.dto.EsCourseSearchDto;
import cn.wmw.xyy.service.IEsCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/es-course")
public class EsCourseController {

    @Autowired
    private IEsCourseService esCourseService;

    @RequestMapping(value="/save",method= RequestMethod.POST)
    public JsonResult save(@RequestBody CourseDoc courseDoc){
        esCourseService.save(courseDoc);
        return JsonResult.success();
    }

    /**
     * es课程搜索接口
     * @param courseSearchDto
     * @return
     */
    @RequestMapping(value="/search",method= RequestMethod.POST)
    public JsonResult search(@RequestBody EsCourseSearchDto courseSearchDto){
        PageList<CourseDoc> pageList = esCourseService.search(courseSearchDto);
        return JsonResult.success(pageList);
    }

}
